<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="com.ophelisis.actions.system.*,
						com.ophelisis.common.consts.*,
						com.ophelisis.common.util.*,
						com.ophelisis.common.consts.ConstPath"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=ConstPath.siteTitle%></title>
<link href="css/common.css" rel="stylesheet" />
<script src="js/jquery-1.7.2.js"></script>
<script src="js/common.js"></script>
<script>
var loginModule = {
		setBinding: function() {
			var that = this;
			
			$("#userId").keydown(function(e) {
				if (e.keyCode == 13) {
					if(that.existUserId()) {
					   $("#userPw").focus();
					}
				}
			});

			$("#userPw").keydown(function(e) {
			    if (e.keyCode == 13) {
			        if(that.existUserPw()) {
			           this.login();
			        }
			    }
			});
			
			$("input").focusin(function() {
			    $(this).addClass("bgWhite");
			    $(this).val("");
			});

			$("input").focusout(function() {
				if ($(this).val() == "") $(this).removeClass("bgWhite");
			});
		},
		
		existUserId: function() {
			if($("input[name=userId]").val()=="" ) {
				loadMessage("아이디를 입력하여 주십시오.", "");
				$("input[name=userId]").focus();
				return false;
			}
			return true;
		},
		
		existUserPw: function() {
			if($("input[name=userPw]").val()=="" ) {
				loadMessage("패스워드를 입력하여 주십시오.", "");
				$("input[name=userPw]").focus();
				return false;
			}
			return true;
		},
		
		login: function() {
			if(!this.existUserId()) return;
			if(!this.existUserPw()) return;
		    
		    $("#formLogin").submit();
		}
};

$(document).ready(function() {
	// 임시
	$("input").addClass("bgWhite");
	$("#userId").val("sysadmin");
	$("#userPw").val("sysadmin@1234");
	
	var preUserId = "${preUserId}";
	var loginMessage = "${loginMessage}";
	
	if (loginMessage != "") {
		loadMessage(loginMessage, "");
		
		$("#userId").val(preUserId);
		$("#userPw").val("").focus();
	}
	
	loginModule.setBinding();
});
</script>
</head>
<body>
<%@ include file="/WEB-INF/jsp/common/resultMessageLocal.jsp"%>
<form id="formLogin" action="login.action" method="post" class="content_login">
	<input type="hidden" id="userUrl" name="userUrl" value="mainPage.action" />
	<table class="loginTable">
		<tr>
			<td>
			<div class="loginLayout">
				<div class="loginForm">
					<div class="loginFormlayout">
						<div class="loginFormTop"></div>
						<div class="loginFormMiddle">for <%=ConstPath.siteTitle%></div>
						<div class="loginFormBottom">
							<div class="idpwin">
								<div><input class="in1" style="width:180px; padding-left:4px;" id="userId" name="userId" title="아이디 입력" type="text" /></div>
								<div><input class="in2" style="width:180px; padding-left:4px;" id="userPw" name="userPw" title="파스워드 입력" type="password" /></div>
								<div class="logbtn"><img src="images/btn/login.gif" class="clickable" onclick="javascript:loginModule.login()" /></div>
							</div>
							<div class="addon"></div>
						</div>
					</div>
				</div>
			</div>
			</td>
		</tr>
	</table>
</form>
</body>
</html>